<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>基本使用</title>
</head>
<body>
    <input type="text" class="name">
    <input type="button" value="get请求" class="get">
    <input type="button" value="post请求" class="post">
    <ul>

    </ul>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <script>
        document.querySelector(".get").onclick=function(){
            axios.get("https://autumnfish.cn/api/joke/list?num=3").then(function(response){
                var ul=document.querySelector('ul');
                for(var i=0;i<3;i++)
                {
                    ul.innerHTML+="<li>"+response.data.jokes[i]+"</li>";
                };
            },function(err){console.log(err);;
            })
        }
        document.querySelector(".get").onclick=function(){
            axios.get("https://autumnfish.cn/api/joke/list?num=6").then(function(response){
                var ul=document.querySelector('ul');
                for(var i=0;i<6;i++)
                {
                    ul.innerHTML+="<li>"+response.data.jokes[i]+"</li>";
                }
            },function(err){
                console.log(err);
                
            })
        }
        document.querySelector(".post").onclick=function(){
            axios.post("https://autumnfish.cn/api/user/reg",{username:"鲤鱼小天使"}).then(function(response){
                alert(response.data);
            },function(err){
                console.log(err);
            })
        }
    </script>
</body>
</html>